import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './login.entity';

@Injectable()
export class LoginService {
  constructor(
    @InjectRepository(User)
    private usersRepository: Repository<User>,
  ) {}

  async create(createCatDto) {
    console.log(createCatDto);
    const res = this.usersRepository.create({
      ...createCatDto,
    });

    // 保存数据
    return await this.usersRepository.save(res);
  }

  findAll() {
    // 调用数据库
    return ['张三', '李四', '王五', '赵柳'];
  }
}
